#! /usr/bin/env bash

set -ex
export NCCL_P2P_DISABLE=1
export HF_HOME=/data/edgar/hf_cache

LR=5e-4
NUM_GPUS=1
LORA_RANK=8
LORA_ALPHA=32
LORA_DROUPOUT=0.1

MAX_SOURCE_LEN=1024
MAX_TARGET_LEN=512
DEV_BATCH_SIZE=2
GRAD_ACCUMULARION_STEPS=1
MAX_STEP=5000
SAVE_INTERVAL=1000

AUTORESUME_FROM_CHECKPOINT=True
RUN_NAME=text
BASE_MODEL_PATH=/data/model_hub/ZhipuAI/chatglm3-6b-base
DATASET_PATH=/data/edgar/project/ChatGLM3/data/gpt_medical_data.jsonl
DATESTR=`date +%Y%m%d-%H%M%S`
OUTPUT_DIR=output/${RUN_NAME}-${DATESTR}-${LR}
MASTER_PORT=$(shuf -n 1 -i 10000-65535)
LORA_PATH=/data/edgar/project/ChatGLM3/finetune_basemodel_demo/output/lora_model_0119/pytorch_model.bin

mkdir -p $OUTPUT_DIR

CUDA_VISIBLE_DEVICES='1' torchrun --standalone --nnodes=1 --nproc_per_node=$NUM_GPUS inference.py \
    --model $BASE_MODEL_PATH \
    --tokenizer $BASE_MODEL_PATH \
    --lora-path $LORA_PATH \
    --lora-rank $LORA_RANK \
    --lora-alpha $LORA_ALPHA \
    --lora-dropout $LORA_DROUPOUT

